<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>  
    <!DOCTYPE html>
    <html>
    <head>
    
    </head>
    <body>
    <div class="easyui-layout" fit="true" style="height:200px;">
    	<div data-options="region:'east',split:true" title="监控台" style="width:300px;">
			<ul class="easyui-tree" id="statslogin"></ul>
		</div>
		
		<div id="content" region="center" title="扫码登录" style="padding:20px;">
		
		
    	<div align="center"  >
    <c:if test="${uuid!=null}">
    	<img id="loginImg" name="loginImg" src="https://login.weixin.qq.com/qrcode/${uuid}">
    </c:if>
    
 <p align="center">点击图片刷新</p>
 <p id="resultLogin" align="center"></p>
    </div>
    	</div>
    	</div>
   
    	<script>
      
    		$(function(){
  				var datas = '';
            	 function runajax(){
         			$.ajax({
         				url:"<%=basePath%>admin/user_getResults.action",
         				datatype:"json",
         				type:"post",
         				async:"true",
         			}).success(function(data){
         				
         				if(datas.split(":")[0]!=data.split(":")[0]){
         				if(data.split(":")[0]=="已经扫描成功，等待确认登陆"){
         					
         					$("#resultLogin").html("已经扫描成功，等待确认登陆");
         				}
         				if(data.split(":")[0]=="开始心跳"){
         					$("#resultLogin").html("开始心跳");
         				}
         				if(data.split(":")[1]=='0'){
         					
         				$("#statslogin").html($("#statslogin").html()+"<li>"+data+"<li>");
         				}else if(data.split(":")[1]=='1101'){
         					$("#statslogin").html($("#statslogin").html()+"<li>"+data+"已下线<li>");
         				}
         			}
         				datas = data;
         			}).error();
         		}
         		
         		setInterval(runajax,2000);
         		
         		function getImgUuid(){
         			$.ajax({
         				url:"<%=basePath%>admin/user_getReUuid.action",
         				datatype:"json",
         				type:"post",
         				async:"true",
         			}).success(function(data){
         				$("#loginImg").attr("src","https://login.weixin.qq.com/qrcode/"+data);
         			}).error(function(data){
         			});
         		}
         		
         		$("#loginImg").click(function(){
         			$.ajax({
         				url:"<%=basePath%>admin/user_getReUuid.action",
         				datatype:"json",
         				type:"post",
         				async:"true",
         			}).success(function(data){
         				$("#loginImg").attr("src","https://login.weixin.qq.com/qrcode/"+data);
         			}).error(function(data){
         			});
         		});
         		
         		setInterval(getImgUuid,245000);
         		
    		});
    		
    	</script>
    </body>
    </html>